import request from '@/utils/request';

export async function getMenus<T>(data?: T): Promise<T> {
  return request('/v1/access/menuList', {
    method: 'POST',
    data,
  });
}

export async function getMenu(menuId: number | null) {
  return request('/v1/access/menuDetail', {
    method: 'POST',
    data: {
      menu_id: menuId,
    },
  });
}

export async function addMenus<T>(data: T): Promise<T> {
  return request('/v1/access/menuAdd', {
    method: 'POST',
    data,
  });
}

export async function updateMenus<T>(data: T): Promise<T> {
  return request('/v1/access/menuModify', {
    method: 'POST',
    data,
  });
}

export async function deleteMenu(menuId: number) {
  return request('/v1/access/menuDelete', {
    method: 'POST',
    data: {
      menu_id: menuId,
    },
  });
}
